home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
disk_425.arc
/
NEWTON.LIB
< prev
next >
Wrap
Text File
|
1985-04-03
|
511b
|
32 lines
{ -> 249 }
procedure newton(var x: real);
const tol = 1.0E-6;
var fx,dfx,dx,x1 : real;
begin { newton }
error:=false;
repeat
x1:=x;
func(x,fx,dfx);
if dfx=0.0 then
begin
error:=true;
x:=1.0;
writeln(chr(7),'ERROR: slope zero')
end
else
begin
dx:=fx/dfx;
x:=x1-dx;
writeln('x=',x,' fx=',fx,' dfx=',dfx)
end
until
error or
(abs(dx)<=abs(tol*x))
end; { newton }